#pragma once

#include <iostream>

class Shape
{
public:
    virtual void   draw()  = 0;
    virtual Shape *clone() = 0;
};

class Rectangle : public Shape
{
public:
    Rectangle()
    {
        m_width  = 0;
        m_height = 0;
    }
    Rectangle(const Rectangle *rectangle)
    {
        m_width  = rectangle->m_width;
        m_height = rectangle->m_height;
    }

public:
    void draw() override
    {
        std::cout << "draw a " << m_width << "x" << m_height << " rectangle." << std::endl;
    }

    Shape *clone() override
    {
        return new Rectangle(this);
    }

    virtual void setSize(int width, int height)
    {
        this->m_width  = width;
        this->m_height = height;
    }

private:
    int m_width;
    int m_height;
};

class Square : public Shape
{
public:
    Square()
    {
        m_width  = 0;
        m_height = 0;
    }
    Square(const Square *square)
    {
        m_width  = square->m_width;
        m_height = square->m_height;
    }

public:
    void draw() override
    {
        std::cout << "draw a " << m_width << "x" << m_height << " square." << std::endl;
    }

    Shape *clone() override
    {
        return new Square(this);
    }

    virtual void setSize(int width, int height)
    {
        this->m_width  = width;
        this->m_height = height;
    }

private:
    int m_width;
    int m_height;
};
